import Vue from 'vue'

const fillzero = function (n) {
  return n < 10 ? '0' + n : n
}

Vue.filter('date', function (time) {
  const d = new Date()
  // 设置日期为当前传进来的时间
  d.setTime(time)
  const year = fillzero(d.getFullYear())
  const month = fillzero(d.getMonth() + 1)
  const date = fillzero(d.getDate())
  const hours = fillzero(d.getHours())
  const minutes = fillzero(d.getMinutes())
  const seconds = fillzero(d.getSeconds())
  return `${year}-${month}-${date} ${hours}:${minutes}:${seconds}`
})
